package com.xpqh.ksg.modular.caseInfo.controller;


import com.xpqh.ksg.base.BaseController;
import com.xpqh.ksg.modular.caseInfo.dto.KsgCaseListByPcRespDTO;
import com.xpqh.ksg.modular.caseInfo.dto.KsgCaseListReqDTO;
import com.xpqh.ksg.modular.caseInfo.service.CaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "ksg")
public class KsgCaseListByPcController extends BaseController {

    @Autowired
    private CaseInfoService caseInfoService;



    @PostMapping("/caseListByPc")
    public com.xpqh.ksg.base.BaseResponseDTO list(@Valid @RequestBody com.xpqh.ksg.modular.caseInfo.dto.KsgCaseListReqDTO req) {
        KsgCaseListByPcRespDTO respDTO = new KsgCaseListByPcRespDTO();
        respDTO.setCount(caseInfoService.getCaseListCount(req.getVehicleBrand(),req.getVehicleModel(),req.getProductName(),req.getProductSeries(),req.getSearch(),req.getCaseType(),req.getKind(),req.getLanguage()));
        respDTO.setCaseList(caseInfoService.getCaseList(req.getVehicleBrand(),req.getVehicleModel(),req.getProductName(),req.getProductSeries(),req.getSearch(),req.getCaseType(),req.getKind(),req.getLanguage(),req.getLabel(),req.getPageNo(),req.getPageSize()));

        return renderResultOk(respDTO);
    }

}
